package com.java46.carera.application.controller;

import com.java46.carera.base.entity.Application;
import com.java46.carera.base.entity.JsonResult;
import com.java46.carera.application.service.ApplicationService;
import com.java46.carera.base.exception.BusinessException;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/Application")
public class ApplicationController {
    @Autowired
    private ApplicationService applicationService;

    @RequestMapping("/add")
    @ResponseBody
    public JsonResult addApplication(Application application){
        return applicationService.addApplication(application);
    }

    @RequestMapping("/mod")
    @ResponseBody
    public JsonResult modApplication(Application application){
        return applicationService.modApplication(application);
    }

    @RequestMapping("/delete")
    @ResponseBody
    public JsonResult deleteApplication(Integer appid){
        return applicationService.deleteApplication(appid);
    }

    @RequestMapping("/queryAll")
    @ResponseBody
    public JsonResult queryAll(@Param("keyword") String keyword, Integer pageNum){
        return applicationService.queryAll(keyword, pageNum);
    }

    @RequestMapping("/queryById")
    @ResponseBody
    public JsonResult queryById(Integer appid){
        return applicationService.queryApplicationById(appid);
    }
}
